package com.qf.commerce.controller;

import com.qf.commerce.entity.Evaluate;
import com.qf.commerce.resp.ResponseResult;
import com.qf.commerce.service.CommodityEvaluateService;
import com.qf.commerce.vo.CommodityEvaluateVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author peng
 * @Date 2023/9/13 10:15
 * @Version 1.0.0
 */
@RestController
@RequestMapping("account")
public class CommodityEvaluateController {
    @Autowired
    private CommodityEvaluateService accountService;

    //    根据评论信息查询数据 展示所以评论信息
    @GetMapping("/selectAccountVo")
    public ResponseResult<List<CommodityEvaluateVo>> selectAccountVo(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "2") int size, CommodityEvaluateVo commodityEvaluateVo) {
        return ResponseResult.success(accountService.selectAccountVo(page,size, commodityEvaluateVo));
    }

    //    根据id删除用户评价
    @PutMapping("updateAccount")
    public ResponseResult<Integer> deleteByid(Long accountId) {
        return ResponseResult.success(accountService.deleteByid(accountId));
    }

    //    根据id多删除用户评价
    @PutMapping("/updateAccountById")
    public ResponseResult<Integer> deleteAccountById(@RequestBody List<Long> accountId) {
        return ResponseResult.success(accountService.deleteAccountById(accountId));
    }

//    用户根据id修改评论
    @PutMapping("/amendAccountById")
    public ResponseResult<Integer> updateAccountById(@RequestBody Evaluate evaluate) {
        return ResponseResult.success(accountService.updateAccountById(evaluate.getAccountId(),evaluate));
    }


}
